package top.bug.blog.schedule.job;

import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.springframework.stereotype.Component;
import top.bug.blog.annotation.ScheduledJob;

import java.util.Date;

/**
 * @author <a href="https://github.com/jiusi66">九思.</a>
 * @email 10837907@qq.com
 * @from <a href="https://www.52bug.top">递归茶馆-www.52bug.top</a>
 * @description 示例任务 30天一次
 */
@ScheduledJob(
        jobName = "DemoTask",
        jobGroup = "DEFAULT",
        cronExpression = "0 0 0 1/30 * ? *",
        autoStart = true,
        description = "示例任务"
)
@Component
@Slf4j
public class DynamicTaskJob implements Job {

    @Override
    public void execute(JobExecutionContext context) {
        JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
        String testParam = jobDataMap.getString("testParam");
        log.info("示例任务正在执行...");
        log.info("执行时间: " + new Date());
        log.info("任务参数: " + testParam);
    }
}